<html>
<?php
  require_once 'header.php';
  
  if(isset($_POST["cid"]))
  {
    $idCategory = $_POST["cid"];
  }
  else
  {
    if(isset($_GET["cid"]))
    {
      $idCategory = $_GET["cid"];
    }
  }
  
  if(isset($_POST["ctitle"]))
  {
    $catTitle = $_POST["ctitle"];
  }
  else
  {
    if(isset($_GET["ctitle"]))
    {
      $catTitle = $_GET["ctitle"];
    }
  }
  
  $ConnectDB = new connectDB();
  $SQLList = new sqlList();  
  
  
  $result = $ConnectDB->buildPreparedStatments($SQLList->SelectCategory);
  $result->bind_param( 'i', $idCategory );
  $result->execute();
  $result->bind_result($idPoem, $title);
  $index = 0;
  while ( $rowSet = $result->fetch())
	{
	  $songId[$index] = $idPoem;
	  $songArr[$idPoem] = $title;
	  $index++;
	}
	$result->close();
?>
<body>
<h1><?php print $catTitle; ?></h1>
<ul>
	<?php
	foreach ($songId as $id)
	{
    print "<li><a href='song.php?sid=" . $id . "'>" . $songArr[$id] . "</a></li>\n";
  }
	?>
</ul>
</body>
</html>